<?php
class PageBase{
	var $mysmarty;
	var $db;
	var $tpl;
	public function __construct($tplpath){
		$this->mysmarty = new MySmarty();
		$this->tpl = $tplpath;
	}
	public function assign($tpl_var,$val){
		$this->mysmarty->assign($tpl_var,$val);
	}
	public function display(){
		$this->ParseRequest();
		$this->Ini();
		$this->mysmarty->display($this->tpl);
	}
	public function fetch(){
		$this->ParseRequest();
		$this->Ini();
		return $this->mysmarty->fetch($this->tpl);
	}
	static public function Go($url,$info = '未知错误'){
		if(!isset($_SESSION)) session_start();
		$_SESSION['errorinfo'] = $info;
		header('location:'.$url);
		die;
	}
	static public function Error($info = '未知错误'){
		PageBase::Go('../home/error.php',$info);
	}
	static public function RequireLogin(){
		if(!Auth::islogin())
			PageBase::Error('请先登录.');
	}
	protected function Ini(){}
	protected function ParseRequest(){}
}
?>